<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:aw="clr-namespace:Assergs.Windows"
    >

    <SolidColorBrush x:Key="ScrollBarNormalBorderBrush" Color="{x:Static aw:ScrollBarPallet.ScrollBarNormalBorderBrush}"></SolidColorBrush>

    <!-- ScrollBarBackGround Vertical -->

    <LinearGradientBrush x:Key="VScrollBarBg" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBg1}" Offset="0"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBg2}" Offset="0.3"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBg2}" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="VScrollBarBtnBgMouseOver" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgMouseOver1}" Offset="0"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgMouseOver2}" Offset="0.49"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgMouseOver3}" Offset="0.5"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgMouseOver4}" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="VScrollBarBtnBgPressed" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgPressed1}" Offset="0"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgPressed2}" Offset="0.49"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgPressed3}" Offset="0.5"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgPressed4}" Offset="1"></GradientStop>
    </LinearGradientBrush>

    <!-- ScrollBarThumb Vertical -->

    <LinearGradientBrush x:Key="VScrollBarThumbBackground" StartPoint="0,0.5" EndPoint="1,0.5">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbBackground1}" Offset="0"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbBackground2}" Offset="0.4"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbBackground3}" Offset="0.4"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbBackground4}" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="VScrollBarThumbOverBrush" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbOverBrush1}" Offset="0"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbOverBrush2}" Offset="0.49"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbOverBrush3}" Offset="0.5"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbOverBrush4}" Offset="1"></GradientStop>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="VScrollBarThumbPressedBrush" StartPoint="0,0" EndPoint="1,0">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbPressedBrush1}" Offset="0"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbPressedBrush2}" Offset="0.49"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbPressedBrush3}" Offset="0.5"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbPressedBrush4}" Offset="1"></GradientStop>
    </LinearGradientBrush>

    <!-- ScrollBarBackGround Horizontal -->

    <LinearGradientBrush x:Key="HScrollBarBg" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBg1}" Offset="0"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBg2}" Offset="0.3"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBg2}" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HScrollBarBtnBgMouseOver" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgMouseOver1}" Offset="0"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgMouseOver2}" Offset="0.49"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgMouseOver3}" Offset="0.5"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgMouseOver4}" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HScrollBarBtnBgPressed" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgPressed1}" Offset="0"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgPressed2}" Offset="0.49"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgPressed3}" Offset="0.5"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarBtnBgPressed4}" Offset="1"></GradientStop>
    </LinearGradientBrush>

    <!-- ScrollBarThumb Horizontal -->

    <LinearGradientBrush x:Key="HScrollBarThumbBackground" StartPoint="0.5,0" EndPoint="0.5,1">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbBackground1}" Offset="0"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbBackground2}" Offset="0.4"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbBackground3}" Offset="0.4"/>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbBackground4}" Offset="1"/>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HScrollBarThumbOverBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbOverBrush1}" Offset="0"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbOverBrush2}" Offset="0.49"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbOverBrush3}" Offset="0.5"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbOverBrush4}" Offset="1"></GradientStop>
    </LinearGradientBrush>

    <LinearGradientBrush x:Key="HScrollBarThumbPressedBrush" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbPressedBrush1}" Offset="0"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbPressedBrush2}" Offset="0.49"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbPressedBrush3}" Offset="0.5"></GradientStop>
        <GradientStop Color="{x:Static aw:ScrollBarPallet.ScrollBarThumbPressedBrush4}" Offset="1"></GradientStop>
    </LinearGradientBrush>

    <!-- ScrollBarLineButton -->

    <Style x:Key="VScrollBarLineButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border
                      Name="Border"
                      Margin="1"
                      CornerRadius="1"
                      Background="{DynamicResource VScrollBarBg}"
                      BorderBrush="White"
                      BorderThickness="0">
                        <Path
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          Fill="{DynamicResource GlyphBrush}"
                          Data="{Binding Path=Content,RelativeSource={RelativeSource TemplatedParent}}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource VScrollBarBtnBgMouseOver}" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="1"/>
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ScrollBarNormalBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource VScrollBarBtnBgPressed}" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="1" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ScrollBarNormalBorderBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HScrollBarLineButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border
                      Name="Border"
                      Margin="1"
                      CornerRadius="1"
                      Background="{DynamicResource HScrollBarBg}"
                      BorderBrush="White"
                      BorderThickness="0">
                        <Path
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          Fill="{DynamicResource GlyphBrush}"
                          Data="{Binding Path=Content,RelativeSource={RelativeSource TemplatedParent}}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="True">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource HScrollBarBtnBgMouseOver}" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="1"/>
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ScrollBarNormalBorderBrush}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource HScrollBarBtnBgPressed}" />
                            <Setter TargetName="Border" Property="BorderThickness" Value="1" />
                            <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource ScrollBarNormalBorderBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent" />
                </ControlTemplate>
            </Setter.Value>

        </Setter>
    </Style>

    <Style x:Key="VScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border
                      Name="Border"
                      CornerRadius="2"
                      BorderBrush="{DynamicResource ScrollBarNormalBorderBrush}"
                      Background="{DynamicResource VScrollBarThumbBackground}"
                      BorderThickness="1">
                        <Path Fill="Black" VerticalAlignment="Center" HorizontalAlignment="Center" Opacity="0.4"
                              Data="M 0 0 L 8 0 L 8 1 L 0 1 Z M 0 2 L 8 2 L 8 3 L 0 3 Z M 0 4 L 8 4 L 8 5 L 0 5 Z M 0 6 L 8 6 L 8 7 L 0 7 Z">
                        </Path>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource VScrollBarThumbOverBrush}" />
                        </Trigger>
                        <Trigger Property="IsDragging" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource VScrollBarThumbPressedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border
                      Name="Border"
                      CornerRadius="2"
                      BorderBrush="{DynamicResource ScrollBarNormalBorderBrush}"
                      Background="{DynamicResource HScrollBarThumbBackground}"
                      BorderThickness="1">
                        <Path Fill="Black" VerticalAlignment="Center" HorizontalAlignment="Center" Opacity="0.4"
                              Data="M 0 0 L 8 0 L 8 1 L 0 1 Z M 0 2 L 8 2 L 8 3 L 0 3 Z M 0 4 L 8 4 L 8 5 L 0 5 Z M 0 6 L 8 6 L 8 7 L 0 7 Z">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <RotateTransform Angle="90"></RotateTransform>
                                    <TranslateTransform X="8"></TranslateTransform>
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource HScrollBarThumbOverBrush}" />
                        </Trigger>
                        <Trigger Property="IsDragging" Value="true">
                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource HScrollBarThumbPressedBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid >
            <Grid.RowDefinitions>
                <RowDefinition MaxHeight="18"/>
                <RowDefinition Height="0.00001*"/>
                <RowDefinition MaxHeight="18"/>
            </Grid.RowDefinitions>
            <Border
              Grid.RowSpan="3"
              CornerRadius="2"
              BorderThickness="1"
              BorderBrush="{DynamicResource ScrollBarNormalBorderBrush}"
              Background="{DynamicResource VScrollBarBg}">

            </Border>
            <RepeatButton
              Grid.Row="0"
              Style="{DynamicResource VScrollBarLineButton}"
              IsEnabled="{TemplateBinding IsMouseOver}"
              Height="18"
              Command="ScrollBar.LineUpCommand"
              Content="M 0 5 L 10 5 L 5 0 Z" />
            <Track
              Name="PART_Track"
              Grid.Row="1"
              IsDirectionReversed="true">
                <Track.DecreaseRepeatButton>
                    <RepeatButton
                      Style="{DynamicResource ScrollBarPageButton}"
                      Command="ScrollBar.PageUpCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb
                      Style="{DynamicResource VScrollBarThumb}"
                      Margin="1,0,1,0"/>
                </Track.Thumb>

                <Track.IncreaseRepeatButton>
                    <RepeatButton
                      Style="{DynamicResource ScrollBarPageButton}"
                      Command="ScrollBar.PageDownCommand" />
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton
              Grid.Row="3"
              Style="{DynamicResource VScrollBarLineButton}"
              IsEnabled="{TemplateBinding IsMouseOver}"
              Height="18"
              Command="ScrollBar.LineDownCommand"
              Content="M 0 0 L 5 5 L 10 0 Z"/>
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="18"/>
                <ColumnDefinition Width="0.00001*"/>
                <ColumnDefinition MaxWidth="18"/>
            </Grid.ColumnDefinitions>
            <Border
              Grid.ColumnSpan="3"
              CornerRadius="2"
              Background="{DynamicResource HScrollBarBg}"/>
            <RepeatButton
              Grid.Column="0"
              Style="{DynamicResource HScrollBarLineButton}"
              IsEnabled="{TemplateBinding IsMouseOver}"
              Width="18"
              Command="ScrollBar.LineLeftCommand"
              Content="M 5 0 L 5 10 L 0 5 Z" />
            <Track
              Name="PART_Track"
              Grid.Column="1"
              IsDirectionReversed="False">
                <Track.DecreaseRepeatButton>
                    <RepeatButton
                      Style="{DynamicResource ScrollBarPageButton}"
                      Command="ScrollBar.PageLeftCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb
                      Style="{DynamicResource HScrollBarThumb}"
                      Margin="0,1,0,1"/>
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton
                      Style="{DynamicResource ScrollBarPageButton}"
                      Command="ScrollBar.PageRightCommand" />
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton
              Grid.Column="3"
              Style="{DynamicResource HScrollBarLineButton}"
              IsEnabled="{TemplateBinding IsMouseOver}"
              Width="18"
              Command="ScrollBar.LineRightCommand"
              Content="M 0 0 L 5 5 L 0 10 Z"/>
        </Grid>
    </ControlTemplate>

    <Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
        <Setter Property="Background" Value="Black"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="Height" Value="16" />
                <Setter Property="Template" Value="{DynamicResource HorizontalScrollBar}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="16"/>
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Template" Value="{DynamicResource VerticalScrollBar}" />
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>